<template>
	<view class="container">
		<view class="status_bar"></view>
		<scroll-view class="body" scroll-y="true">
			<!--当前班组-->
			<view class="card" style="margin: 0 20upx 20upx;">
				<view class="title">
					<view class="name">当前班组巡检统计</view>
				</view>
				<view class="item">
					<view class="flex-row">
						<view class="label">班组名称：{{ form.deptName }}</view>
						<view class="value">已巡检：共<text style="color: #00CE1C;">{{ form.hasCheck || 0 }}</text>条</view>
					</view>
				</view>
				<view class="item">
					<view class="flex-row">
						<view class="label">应&nbsp;&nbsp;巡&nbsp;&nbsp;检：共<text style="color: #00CE1C;">{{ form.allCheck || 0 }}</text>条</view>
						<view class="value">未巡检：共<text style="color: red;">{{ form.noCheck || 0 }}</text>条</view>
					</view>
				</view>
			</view>
			<!--近两日班组隐患信息-->
			<view class="card latest" style="margin-bottom: 20upx;border-radius: 0;height: initial;padding-bottom: 2upx;">
				<view class="title">
					<view class="name">近两日班组隐患信息</view>
				</view>
				<view v-for="(item, index) in latest" :key="index" class="card" style="height: initial;margin-bottom: 20upx;">
					<view class="item flex-row">
						<view class="left">
							<view>风险名称：{{ item.fxName }}</view>
							<view>整改责任人：{{ item.done_username }}</view>
							<view>发现时间：{{ item.find_time }}</view>
							<view>整改期限：{{ item.limit_time }}</view>
							<view>请及时整改，消除隐患，安全生成！</view>
						</view>
						<view v-if="item.status" class="right">
							<image src="../../static/img/risk/checked-flag.png"></image>
							<view style="color: #007AFF;">已整改</view>
						</view>
						<view v-else class="right">
							<image src="../../static/img/risk/uncheck.png"></image>
							<view style="color: red;">未整改</view>
						</view>
					</view>
				</view>
			</view>
			<!--交班信息-->
			<view class="card" style="height: initial;padding-bottom: 20upx;margin: 0 20upx 20upx;">
				<view class="title">
					<view class="name">交班信息</view>
				</view>
				<view class="item">交班人：{{ handle.userName || '' }}</view>
				<view class="item">交班时间：{{ handle.addtime || '' }}</view>
				<view class="item">交接意见：{{ handle.send_sugg || '' }}</view>
				<view class="item">交班人签字：</view>
				<view class="item">
					<view v-if="handle.send_sign" class="sign-image">
						<image :src="handle.send_sign"></image>
					</view>
				</view>
			</view>
			<!--接班检查信息-->
			<!--<view class="card" style="height: initial;padding-bottom: 20upx;margin: 0 20upx 20upx;" v-if="form.need_check==2">
				<view class="title">
					<view class="name">接班检查信息</view>
				</view>
				<view class="item">检查名称：{{ handle.check_title || '' }}</view>
				<view class="item">检查时间：{{ handle.check_time || '' }}</view>
				<view class="item">检查状态：{{ handle.check_status_text || '' }}</view>
				 <view class="item">
					<text>现场视图</text>
					<upload :files="pics" showBtn="false" icon="false"></upload>
				</view> 
				<view class="item">检查人员签字：{{ handle.touserName || '' }}</view>
				<view class="item">
					<view v-if="handle.recive_sign" class="sign-image">
						<image :src="handle.recive_sign"></image>
					</view>
				</view>
			</view>-->
			<view class="card" style="height: initial;padding-bottom: 20upx;margin: 0 20upx 20upx;" v-if="form.need_check==2">
				<view class="title">
					<view class="name">接班信息</view>
				</view>
				<view class="item">接班人：{{ handle.reciveName || '' }}</view>
				<view class="item">接班时间：{{ handle.recive_time || '' }}</view>
				<view class="item">接班人签字：</view>
				<view class="item">
					<view v-if="handle.recive_sign" class="sign-image">
						<image :src="handle.recive_sign"></image>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
export default{
	data(){
		return {
			id: '',
			to_username: '',
			form: {
				userid: uni.getStorageSync('userid'),
				send_sugg: '',
				to_user: '',
				send_sign: ''
			},
			latest: [],
			handle: {}
		}
	},
	onLoad(option){
		this.id = option.id;
		this.getDetail();
	},
	methods: {
		// 获取交接班据
		getDetail(){
			let _this = this;
			uni.request({
				url: this.$API.riskHandleDetail,
				data: {
					id: this.id,
					userid: this.form.userid,
				},
				header: this.$API.get_head(),
				success: (res)=>{
					_this.form = res.data.data.tongji;
					_this.latest = res.data.data.list;
					_this.handle = res.data.data.jiaojieInfo;
					
					// 处理检查状态
					if(_this.handle.check_status == 0) _this.handle.check_status_test = '未检查';
					if(_this.handle.check_status == 1) _this.handle.check_status_test = '已巡检无隐患';
					if(_this.handle.check_status == 2) _this.handle.check_status_test = '一般事故隐患';
					if(_this.handle.check_status == 3) _this.handle.check_status_test = '疑似重大事故隐患';
					if(_this.handle.check_status == 4) _this.handle.check_status_test = '已存在未整改隐患';
				}
			});
		},
	}
}
</script>

<style scoped>
.container{
	padding: 20upx 0;
	box-sizing: border-box;
}
.status_bar{
	height: var(--status-bar-height);
}
.body{
	height: calc(100vh - var(--status-bar-height));
}
button{
	width: 240upx;
	height: 64upx;
	line-height: 64upx;
	font-size: 28upx;
	margin: 80upx auto;
}

.sign-image{
	width: 100%;
	height: 300upx;
	margin-bottom: 20upx;
	background: #F0F0F0;
}
.sign-image image{
	width: 100% !important;
	height: 100% !important;
}

/*卡片*/
.card{
	height: 150upx;
	background: #fff;
	margin-bottom: 16upx;
	border-radius: 16upx;
	padding: 14upx 20upx 0;
	box-shadow: 0 2upx 4upx #DEDEDE;
}
.card .title{
	margin-bottom: 6upx;
}
.card .title view{
	font-size: 28upx;
	width: calc((100% - 100upx) / 2);
}
.card .title view.name,
.card .item .left view:first-child{
	text-indent: 16upx;
	position: relative;
}
.card .title view.name::before,
.card .item .left view:first-child::before{
	content: '';
	width: 6upx;
	height: 26upx;
	background: #179DFE;
	border-radius: 6upx;
	position: absolute;
	top: 14upx;
	left: 0;
}
.card.latest .title view.name::before,
.card .item .left view:first-child::before{
	background-color: red;
}
.card .item *{
	font-size: 26upx;
}
.card .item image{
	width: 80upx;
	height: 100upx;
}
.card .item .label,
.card .item .value{
	width: 50%;
	line-height: 1.6;
}
.card .item .info-label{
	width: 190upx;
}
.card .item .info-input{
	width: calc(100% - 190upx);
	border-radius: 10upx;
	box-sizing: border-box;
}
.card .item .info-input textarea{
	width: 100%;
	height: 140upx;
	padding: 14upx;
	box-sizing: border-box;
}.card .card{
	border: 2upx solid #F2F2F2;
}
</style>
